const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');
const schema = new mongoose.Schema({
  username:{
    type: String,
    required: true,
    minlength: 1,
    maxlength: 20
  },
  password: {
    type: String,
    select: false,
    set(val){
      // const salt = await bcryptjs.genSaltSync(10);
      // const pass = await bcryptjs.hashSync(val, salt);
      // return pass
      return bcrypt.hashSync(val, 10)
    },
    required: true
  }
});
const AdminUser = mongoose.model('AdminUser', schema);
module.exports = AdminUser;
